{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "format(1, \"b\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "format(1, \"b\").count(\"1\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/counting-bits\n",
    "\n",
    "\n",
    "Runtime: 96 ms, faster than 35.74% of Python3 online submissions for Counting Bits.\n",
    "Memory Usage: 20.9 MB, less than 38.77% of Python3 online submissions for Counting Bits.\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def countBits(self, num: int) -> List[int]:\n",
    "        r = []\n",
    "        for i in range(0, num+1):\n",
    "            r.append(format(i, \"b\").count(\"1\"))\n",
    "        return r\n",
    "```\n",
    "\n",
    "\n",
    "Spent 5 minutes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
